package com.example.ibo.lollipopdemo;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;

import com.example.ibo.lollipopdemo.Adapters.MyPagerAdapter;
import com.example.ibo.lollipopdemo.PullZom.PullZoomActivity;
import com.example.ibo.lollipopdemo.SilidingTab.SlidingTabLayout;

public class MainActivity extends ActionBarActivity {

    private Toolbar toolbar;
    private ViewPager pager;
    private SlidingTabLayout tabLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        toolbar = (Toolbar) findViewById(R.id.app_bar);
        setSupportActionBar(toolbar);

        NavigationDrawerFragment drawerFragment = (NavigationDrawerFragment) getSupportFragmentManager().findFragmentById(R.id.man);
        drawerFragment.setUp(R.id.man, (DrawerLayout) findViewById(R.id.drawer_layout), toolbar);

        pager = (ViewPager) findViewById(R.id.pager);
        pager.setAdapter(new MyPagerAdapter(getSupportFragmentManager(), this));

        tabLayout = (SlidingTabLayout) findViewById(R.id.tabs);
        tabLayout.setDistributeEvenly(true);
        tabLayout.setSelectedIndicatorColors(Color.WHITE);
        tabLayout.setCustomTabView(R.layout.custom_tab, R.id.tab_text);
        tabLayout.setViewPager(pager);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();

        if (id == R.id.action_settings) {
            Snackbar.make(toolbar, "Setting xu !", Snackbar.LENGTH_SHORT).setAction("Action", null).show();
        }
        if (id == R.id.action_pull_zoom) {
            startActivity(new Intent(this, PullZoomActivity.class));
        }
        return super.onOptionsItemSelected(item);
    }


}
